<?php
include_once 'app/until/GFW_HTTP.php';
class UserEdit extends GetData{

	private $daten;
	private $User_Id;

	public function __construct($match){
		$this->daten = $match;
	}

	public function getWort(RainTPL $design){
		$this->design = $design;
		parent::GetData();
		$user = Model_Db_User();
		
		if($this->design->get->imagedel){
			$this->design->File->delfile($this->design->Settings['user_image_dir'].'/'.$this->ActivUser->bild_50);
			$this->design->File->delfile($this->design->Settings['user_image_dir'].'/'.$this->ActivUser->bild_180);
			$user->updatePic($this->ActivUser->id);
			
			HTTP::redirect ( BASE_URL . '/useredit' );
		}
		if($this->design->File->image){
			$PhpThumbFactory = new PhpThumbFactory();
			$thumb = $PhpThumbFactory->create($this->design->File->image['tmp_name']);
			
			if(!is_dir($this->design->Settings['user_image_dir'].'/'.(int)($this->ActivUser->id/IMAGE_FOLDER_SIZE))){
				mkdir($this->design->Settings['user_image_dir'].'/'.(int)($this->ActivUser->id/IMAGE_FOLDER_SIZE));
			}
			
			$thumb->resize(180, 0)->save($this->design->Settings['user_image_dir'].'/'.(int)($this->ActivUser->id/IMAGE_FOLDER_SIZE).'/'.md5('180'.$this->design->File->image['name']));
			$thumb->resize(50, 50)->save($this->design->Settings['user_image_dir'].'/'.(int)($this->ActivUser->id/IMAGE_FOLDER_SIZE).'/'.md5('50'.$this->design->File->image['name']));
			
			$this->design->File->delfile($this->design->Settings['user_image_dir'].'/'.$this->ActivUser->bild_50);
			$this->design->File->delfile($this->design->Settings['user_image_dir'].'/'.$this->ActivUser->bild_180);
			
			$user->updatePic($this->ActivUser->id, (int)($this->ActivUser->id/IMAGE_FOLDER_SIZE).'/'.md5('50'.$this->design->File->image['name']), (int)($this->ActivUser->id/IMAGE_FOLDER_SIZE).'/'.md5('180'.$this->design->File->image['name']));
	
			HTTP::redirect ( BASE_URL . '/useredit' );
		}
		
        $navi = user_page_static::getNavi("Pages","Deine Seiten");		
		$this->design->assign ('navi',$navi);	
		
		$this->design->assign ('css', "useredit");
       	$this->design->assign ('js', "jsUseredit");
       	
		if( $cache = $this->design->cache( $this->design->ln.'/User/edit/user', $expire_time = 0 ) )
		 {
		 	echo $cache;
		 }
		 else
		 {
		 	$this->design->draw( $this->design->ln.'/User/edit/user' );
		 }
	}
}
?>